package com.sgcc.fj.pmos.common.utils;

import com.alibaba.android.arouter.utils.TextUtils;
import com.sgcc.fj.pmos.common.http.HttpInterConst;
import com.sgcc.fj.pmos.common.http.HttpRequestUtils;
import com.sgcc.fj.pmos.common.http.MvcNetCallback;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

/**
 * 埋点工具类
 */
public class BurialPointUtils {

    /**
     * LOGIN 登录
     * REGISTER 注册
     * BARGAIN_ORDER 议价下单
     * IMMEDIATE_ORDER 立即下单
     * ELECTRIC_CHANGE 电量变更
     * PRICE_CHANGE 电价变更
     * CANCEL_ORDER 取消订单
     * TERMINATION_CONTRACT 合约解除
     * SUPPLEMENTARY_AGREEMENT 补充协议
     * APP_OPEN app打开
     * INFORMATION_DISCLOSURE 信息披露
     */
    public enum mPoint {
        LOGIN, REGISTER, BARGAIN_ORDER, IMMEDIATE_ORDER, ELECTRIC_CHANGE, PRICE_CHANGE,
        CANCEL_ORDER, TERMINATION_CONTRACT, SUPPLEMENTARY_AGREEMENT, APP_OPEN, INFORMATION_DISCLOSURE
    }

    /**
     * 把埋点数据给平台
     *
     * @param type
     */
    public static void onBurialPoint(mPoint type) {
        String point = "";
        switch (type) {
            case LOGIN:
                break;
            case REGISTER:
                point = "registerNum";
                break;
            case BARGAIN_ORDER:
                break;
            case IMMEDIATE_ORDER:
                break;
            case ELECTRIC_CHANGE:
                break;
            case PRICE_CHANGE:
                break;
            case CANCEL_ORDER:
                break;
            case TERMINATION_CONTRACT:
                break;
            case SUPPLEMENTARY_AGREEMENT:
                break;
            case APP_OPEN:
                point = "appOpenNum";
                break;
            case INFORMATION_DISCLOSURE:
                point = "informationClickNum";
                break;
        }
        if (TextUtils.isEmpty(point)) {
            return;
        }
        Map<String, Object> params = new HashMap<>();
        params.put("targetType", point);
        params.put("targetValue", 1);
        params.put("operatingSystem", "Android");
        HttpRequestUtils.getInstance().request(params, HttpInterConst.BURIALPOINT_UPDATE, new MvcNetCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
            }

            @Override
            public void onResponse(Object response, int id) {
                super.onResponse(response, id);
            }
        });
    }
}
